﻿using System.Collections.Generic;
using System.Configuration;

namespace Mysoft.Platform.Component.Config
{
	internal class AppConfiguration
	{
		private static readonly object _lock = new object();

		public static string AuthorizedFailedRedirectUrl
		{
			get { return "~/Error/Index"; }
		}

		public static string LoginRedirectUrl
		{
			get { return "~/Login.aspx"; }
		}

		private static List<string> _adminGroup;

		public static List<string> AdminGroup
		{
			get
			{
				if (_adminGroup == null)
				{
					lock (_lock)
					{
						string[] admins = ConfigurationManager.AppSettings["AdminGroup"].Split(',');
						string domain = ConfigurationManager.AppSettings["Domain"];
						if (string.IsNullOrEmpty(domain))
						{
							domain = "MYSOFT";
						}

						_adminGroup = new List<string>();
						foreach (string admin in admins)
						{
							_adminGroup.Add(string.Format(@"{0}\{1}", domain, admin).ToLower());
						}
					}
				}

				return _adminGroup;
			}
		}

		public static string ConnectionString
		{
			get { return ConfigurationManager.AppSettings["Default"]; }
		}
	}
}